package de.hauschild.gmltracer.tracer;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.math.geometry.Vector3D;

public class Ray {

  private final Vector3D start;
  private final Vector3D end;

  public Ray(final Vector3D theStart, final Vector3D theEnd) {
    start = theStart;
    end = theEnd;
  }

  @Override
  public boolean equals(final Object obj) {
    if (this == obj) {
      return true;
    }
    if (!(obj instanceof Ray)) {
      return false;
    }
    final Ray rhs = (Ray) obj;
    return new EqualsBuilder().append(getStart(), rhs.getStart()).append(getEnd(), rhs.getEnd()).isEquals();
  }

  public Vector3D getEnd() {
    return end;
  }

  public Vector3D getStart() {
    return start;
  }

  @Override
  public int hashCode() {
    return new HashCodeBuilder().append(getStart()).append(getEnd()).toHashCode();
  }

  @Override
  public String toString() {
    return String.format("%s -> %s", getStart(), getEnd());
  }
}
